/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            adminComplaintInfo: {
                complaints: [],
                states: [{
                    statusCd: '',
                    name: '全部'
                }, {
                    statusCd: 'W',
                    name: '处理中'
                }, {
                    statusCd: 'C',
                    name: '处理完成'
                }],
                complaintTypes:[],
                total: 0,
                records: 1,
                moreCondition: false,
                complaintName: '',
                conditions: {
                    complaintId: '',
                    typeCd: '',
                    complaintName: '',
                    tel: '',
                    roomName: '',
                    state: '',
                    startTime: '',
                    endTime: ''
                }
            }
        },
        _initMethod: function () {
            vc.initDate('start_time', function (_value) {
                $that.adminComplaintInfo.conditions.startTime = _value;
            });

            vc.initDate('end_time', function (_value) {
                $that.adminComplaintInfo.conditions.endTime = _value;
            });

            $that._listAdminComplaints(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('selectAdminCommunity','changeCommunity',function(_community){
                $that.adminComplaintInfo.conditions.communityId = _community.communityId;
                $that._listAdminComplaints(DEFAULT_PAGE, DEFAULT_ROWS);
            })
            vc.on('adminComplaint', 'listAdminComplaint', function (_param) {
                $that._listAdminComplaints(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listAdminComplaints(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listAdminComplaints: function (_page, _rows) {
                $that.adminComplaintInfo.conditions.page = _page;
                $that.adminComplaintInfo.conditions.row = _rows;
                let param = {
                    params: $that.adminComplaintInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/complaint.listAdminComplaints',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.adminComplaintInfo.total = _json.total;
                        $that.adminComplaintInfo.records = _json.records;
                        $that.adminComplaintInfo.complaints = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.adminComplaintInfo.records,
                            dataCount: $that.adminComplaintInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            swatchAdminComplaintState: function (item) {
                $that.adminComplaintInfo.conditions.state = item.statusCd;
                $that._listAdminComplaints(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //查询
            _queryAdminComplaintMethod: function () {
                $that._listAdminComplaints(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openAdminComplaintDetailModel: function (_adminComplaint) {
                //vc.emit('adminComplaintDetail', 'openAdminComplaintDetailModal', _adminComplaint);
                vc.jumpToPage('/#/pages/complaint/adminComplaintDetail?complaintId='+_adminComplaint.complaintId);
            },
            
        }
    });
})(window.vc);